/*
ID:fuxiang2
PROG: ride
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

long fun(string a)
{
	int len = a.length();
	long re = 1;
	for (int i = 0 ; i < len ; i ++){
		re = re * (a[i] - 'A' + 1);
	}
	return re;
}
int main() {
	ofstream fout ("ride.out");
	ifstream fin ("ride.in");
	string a;
	string b;
	fin >> a >> b;
	
	long rea = fun(a);
	long reb = fun(b);
	if(  rea%47 == reb%47  )
		fout<< "GO"  << endl;
	else
		fout<< "STAY"  << endl;
	return 0;
}